import { postAction, httpAction } from '@/api/action'

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true
 * }
 * @param parameter
 * @returns {*}
 */
export const login = params => postAction('/account/login', params)

/**
 *  @description
 * @param {*} logoutToken
 */
export const logout = logoutToken =>
  httpAction('/account/logout', null, 'get', {
    'Content-Type': 'application/json;charset=UTF-8',
    'X-Access-Token': logoutToken
  })

/**
 * 手机短信验证码登录
 * @param {*} parameter
 */
export function phoneLogin(parameter) {
  return axios({
    url: '/account/login/phoneLogin',
    method: 'post',
    data: parameter
  })
}

/**
 * 短信模板：0 .登录模板、1.注册模板、2.密码重置
 * @param {*} parameter
 */
export function getSmsCaptcha(parameter) {
  return axios({
    url: '/account/sms/send',
    method: 'post',
    data: parameter
  })
}
